<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="doctest-DocTestParser.html" />
<link rel="prev" href="doctest-Example.html" />
<link rel="parent" href="doctest-advanced-api.html" />
<link rel="next" href="doctest-DocTestParser.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>23.2.6.3 DocTestFinder objects</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="23.2.6.2 example Objects"
  href="doctest-Example.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="23.2.6 advanced API"
  href="doctest-advanced-api.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="23.2.6.4 doctestparser objects"
  href="doctest-DocTestParser.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="doctest-Example.html">23.2.6.2 Example Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="doctest-advanced-api.html">23.2.6 Advanced API</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="doctest-DocTestParser.html">23.2.6.4 DocTestParser objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h3><a name="SECTION0025263000000000000000"></a><a name="doctest-DocTestFinder"></a>
<br>
23.2.6.3 DocTestFinder objects
</h3>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-4971' xml:id='l2h-4971' class="class">DocTestFinder</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>verbose</var><big>]</big><var></var><big>[</big><var>,
                                parser</var><big>]</big><var></var><big>[</big><var>, recurse</var><big>]</big><var></var><big>[</big><var>,
                                exclude_empty</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
    A processing class used to extract the <tt class="class">DocTest</tt>s that are
    relevant to a given object, from its docstring and the docstrings
    of its contained objects.  <tt class="class">DocTest</tt>s can currently be
    extracted from the following object types: modules, functions,
    classes, methods, staticmethods, classmethods, and properties.

<p>
The optional argument <var>verbose</var> can be used to display the
    objects searched by the finder.  It defaults to <code>False</code> (no
    output).

<p>
The optional argument <var>parser</var> specifies the
    <tt class="class">DocTestParser</tt> object (or a drop-in replacement) that is
    used to extract doctests from docstrings.

<p>
If the optional argument <var>recurse</var> is false, then
    <tt class="method">DocTestFinder.find()</tt> will only examine the given object,
    and not any contained objects.

<p>
If the optional argument <var>exclude_empty</var> is false, then
    <tt class="method">DocTestFinder.find()</tt> will include tests for objects with
    empty docstrings.

<p>

<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<tt class="class">DocTestFinder</tt> defines the following method:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-4972' xml:id='l2h-4972' class="method">find</tt></b>(</nobr></td>
  <td><var>obj</var><big>[</big><var>, name</var><big>]</big><var></var><big>[</big><var>,
                   module</var><big>]</big><var></var><big>[</big><var>, globs</var><big>]</big><var></var><big>[</big><var>, extraglobs</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
    Return a list of the <tt class="class">DocTest</tt>s that are defined by
    <var>obj</var>'s docstring, or by any of its contained objects'
    docstrings.

<p>
The optional argument <var>name</var> specifies the object's name; this
    name will be used to construct names for the returned
    <tt class="class">DocTest</tt>s.  If <var>name</var> is not specified, then
    <code><var>obj</var>.__name__</code> is used.

<p>
The optional parameter <var>module</var> is the module that contains
    the given object.  If the module is not specified or is None, then
    the test finder will attempt to automatically determine the
    correct module.  The object's module is used:

<p>

<ul>
<li>As a default namespace, if <var>globs</var> is not specified.
</li>
<li>To prevent the DocTestFinder from extracting DocTests
          from objects that are imported from other modules.  (Contained
          objects with modules other than <var>module</var> are ignored.)
</li>
<li>To find the name of the file containing the object.
</li>
<li>To help find the line number of the object within its file.
    
</li>
</ul>

<p>
If <var>module</var> is <code>False</code>, no attempt to find the module
    will be made.  This is obscure, of use mostly in testing doctest
    itself: if <var>module</var> is <code>False</code>, or is <code>None</code> but
    cannot be found automatically, then all objects are considered to
    belong to the (non-existent) module, so all contained objects will
    (recursively) be searched for doctests.

<p>
The globals for each <tt class="class">DocTest</tt> is formed by combining
    <var>globs</var> and <var>extraglobs</var> (bindings in <var>extraglobs</var>
    override bindings in <var>globs</var>).  A new shallow copy of the globals
    dictionary is created for each <tt class="class">DocTest</tt>.  If <var>globs</var> is
    not specified, then it defaults to the module's <var>__dict__</var>, if
    specified, or <code>{}</code> otherwise.  If <var>extraglobs</var> is not
    specified, then it defaults to <code>{}</code>.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="23.2.6.2 example Objects"
  href="doctest-Example.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="23.2.6 advanced API"
  href="doctest-advanced-api.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="23.2.6.4 doctestparser objects"
  href="doctest-DocTestParser.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="doctest-Example.html">23.2.6.2 Example Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="doctest-advanced-api.html">23.2.6 Advanced API</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="doctest-DocTestParser.html">23.2.6.4 DocTestParser objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
